import 'dart:convert';
import 'dart:io';
import 'package:wanchong/app/home/me.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:image_picker/image_picker.dart';
import 'package:wanchong/api/pet.dart';
import 'package:wanchong/bean/cat_group_entity.dart';
import 'package:wanchong/bean/cats_entity.dart';
import 'package:wanchong/bean/success_entity.dart';
import 'package:wanchong/conf.dart';
import 'package:wanchong/utils/common.dart';
import 'package:wanchong/utils/event_bus.dart';
import 'package:wanchong/utils/upload.dart';
import 'package:wanchong/widget/app_bar.dart';
import 'package:azlistview/azlistview.dart';
import 'package:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:wanchong/widget/loading.dart';
import 'package:wanchong/path.dart';
class AddPet extends StatefulWidget {
  @override
  _AddPetState createState() => _AddPetState();
}

const String MIN_DATETIME = '1970-01-01';
const String MAX_DATETIME = '2019-12-31';
const String INIT_DATETIME = '2019-05-17';
const List SEXS = ["GG", "MM"];
const List HISTORY = ["懵懂少年", "青涩初恋", "久经情场", "专业爸爸"];

class _AddPetState extends State<AddPet> {
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  List<PetCatInfo> _catList = new List();
  PetCatInfo _currentCat = PetCatInfo("0", "", "未选择", "");
  DateTimePickerLocale _locale = DateTimePickerLocale.zh_cn;
  String _format = 'yyyy-MMMM-dd';
  DateTime _dateTime;

  int _days = 0;
  int _years = 0;
  bool _isDay = false;
  var _nowTime = DateTime.now();
  // _nowTime.difference(_da)
  int _current = 0;
  PageController _pageController = PageController();
  bool complated1 = false;
  bool complated2 = false;
  bool complated3 = false;
  bool complated4 = true;
  bool _showTitle = true;
  double _weight = 0.0;
  bool man = true;

  int _suspensionHeight = 20;
  int _itemHeight = 50;
  String _suspensionTag = "";
  List<CatGroupData> _main_cat = List();
  List<CatsData> _cat_data = List();
  String _sex = "GG";
  String _history = "懵懂少年";

  ///选择宠物主分类
  int _current_main_cat = 0;

  ///宠物的生日
  int birthday = 0;

  ///宠物的头像
  String _image;

  ///宠物的详细分类
  String _cat_id = "";

  ///宠物的体重
  int weight = 0;

  ///宠物的性别
  String sex = "1";

  ///宠物的婚恋史
  String history = "1";
  bool finished = false;
  TextEditingController controller = TextEditingController();

  @override
  void initState() {
    _getGroup();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return !finished
        ? Loading()
        : WillPopScope(
            child: Scaffold(
              key: _scaffoldKey,
              resizeToAvoidBottomPadding: false,
              appBar: MyAppBar(
                child: Align(
                  alignment: Alignment.center,
                  child: Stack(
                    children: <Widget>[
                      Center(
                        child: Text(
                          _current == 0
                              ? ""
                              : _current == 1
                                  ? "选择品种"
                                  : _current == 2 ? "" : "",
                          style: TextStyle(
                            fontSize: 18.0,
                            fontWeight: FontWeight.w700,
                            color: Color(0xFF3C4450),
                          ),
                        ),
                      ),
                      GestureDetector(
                        onTap: () {
                          // print("object");
                          _prev();
                        },
                        child: Container(
                          padding: EdgeInsets.only(right: 15.0),
                          color: Colors.transparent,
                          height: double.infinity,
                          child:
                              Image.asset("assets/login/top_return_icon.png"),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              body: PageView(
                controller: _pageController,
                physics: NeverScrollableScrollPhysics(),
                children: <Widget>[
                  pageData(),
                  pageCat(),
                  pageDate(),
                  pageSex()
                ],
              ),
            ),
            onWillPop: () {
              _prev();
            });
  }

  Widget pageData() {
    return Container(
      padding: EdgeInsets.only(left: 46.0, right: 46.0),
      color: Color(0xFFFFFFFF),
      child: Column(
        children: <Widget>[
          SizedBox(
            height: 20.0,
          ),
          Text(
            "添加宠物信息",
            style: TextStyle(
              color: Color(0xFF3C4450),
              fontSize: 24.0,
              fontWeight: FontWeight.w700,
            ),
          ),
          SizedBox(
            height: 35.0,
          ),
          GestureDetector(
            onTap: () {
              getImage();
            },
            child: Container(
              width: 90.0,
              height: 90.0,
              child: ClipOval(
                child: _image == null
                    ? Image.asset(
                        "assets/pet/add_pet_head_portrait_icon.png",
                        fit: BoxFit.cover,
                      )
                    : CachedNetworkImage(
                        imageUrl: _image,
                        fit: BoxFit.cover,
                      ),
              ),
            ),
          ),
          SizedBox(
            height: 15.0,
          ),
          Text(
            "上传宠物头像",
            style: TextStyle(
              color: Color(0xFF647280),
              fontSize: 18.0,
            ),
          ),
          SizedBox(
            height: 10.0,
          ),
          TextField(
            textAlign: TextAlign.center,
            controller: controller,
            style: TextStyle(color: Color(0xFF424D59), fontSize: 24.0),
            keyboardType: TextInputType.text,
            decoration: InputDecoration(
              contentPadding: const EdgeInsets.symmetric(vertical: 4.0),
              border: InputBorder.none,
              hintText: "请输入宠物的爱称",
              hintStyle: TextStyle(
                color: Color(0xFFDBDBDB),
                fontSize: 18.0,
              ),
            ),
            onChanged: (text) {
              setState(() {
                complated1 = _image != null && text.length > 0;
              });
            },
          ),
          SizedBox(
            height: 10.0,
          ),
          Divider(
            color: Color(0xFFDDDDDD),
            height: 1.0,
          ),
          SizedBox(
            height: 65.0,
          ),
          Text(
            "选择宠物的类型",
            style: TextStyle(
              color: Color(0xFF647280),
              fontSize: 18.0,
            ),
          ),
          SizedBox(
            height: 30.0,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: List.generate(
              _main_cat.length,
              (index) {
                return GestureDetector(
                  onTap: () {
                    if (_current_main_cat != _main_cat[index].id) {
                      setState(() {
                        _current_main_cat = _main_cat[index].id;
                      });
                      _getCat(_current_main_cat);
                      // _getCats(_current_main_cat);
                    }
                  },
                  child: Container(
                      width: 90.0,
                      height: 90.0,
                      child: CachedNetworkImage(
                        imageUrl: _current_main_cat != _main_cat[index].id
                            ? _main_cat[index].bgImg
                            : _main_cat[index].checkImg,
                      )),
                );
              },
            ),
          ),
          Expanded(
            child: Container(),
          ),
          GestureDetector(
            onTap: () {
              ///进入主页面
              if (complated1) {
                ///判断当前页是否完成
                _next();
              } else {
                alert("请填写完整资料");
              }
            },
            child: ClipRRect(
              borderRadius: BorderRadius.circular(25.0),
              child: Container(
                alignment: Alignment.center,
                child: Text(
                  "下一步",
                  style: TextStyle(color: Color(0xFFFFFFFF), fontSize: 18.0),
                ),
                color: complated1 ? Color(0xFFFFCC33) : Color(0xFFFFE599),
                height: 50.0,
              ),
            ),
          ),
          SizedBox(
            height: 50.0,
          )
        ],
      ),
    );
  }

  Widget pageCat() {
    return Column(
      children: [
        Container(
          alignment: Alignment.centerLeft,
          padding: const EdgeInsets.only(left: 15.0),
          height: 50.0,
          child: Text("当前选择: " + _currentCat.id == "0" ? "" : _currentCat.name),
        ),
        Expanded(
          flex: 1,
          // child: color: Colors.white,
          child: AzListView(
            data: _catList,
            itemBuilder: (context, model) => _buildListItem(model),
            suspensionWidget: _buildSusWidget(_suspensionTag),
            isUseRealIndex: true,
            itemHeight: _itemHeight,
            suspensionHeight: _suspensionHeight,
            onSusTagChanged: _onSusTagChanged,
            // indexBarBuilder: (BuildContext context, List<String> tags,
            //     IndexBarTouchCallback onTouch) {
            //   return Container(
            //     margin: EdgeInsets.symmetric(vertical: 16.0, horizontal: 8.0),
            //     decoration: BoxDecoration(
            //         color: Colors.grey[50],
            //         borderRadius: BorderRadius.circular(20.0),
            //         border: Border.all(color: Colors.grey[300], width: .5)),
            //     child: ClipRRect(
            //       borderRadius: BorderRadius.circular(20.0),
            //       child: IndexBar(
            //         data: tags,
            //         itemHeight: 20,
            //         onTouch: (details) {
            //           onTouch(details);
            //         },
            //       ),
            //     ),
            //   );
            // },
            // indexHintBuilder: (context, hint) {
            //   return Container(
            //     alignment: Alignment.center,
            //     width: 60.0,
            //     height: 60.0,
            //     decoration: BoxDecoration(
            //       color: Colors.blue[700].withAlpha(200),
            //       shape: BoxShape.circle,
            //     ),
            //     child: Text(hint,
            //         style: TextStyle(color: Colors.white, fontSize: 30.0)),
            //   );
            // },
          ),
        )
      ],
    );
  }

  Widget _buildListItem(PetCatInfo model) {
    String susTag = model.getSuspensionTag();
    return Column(
      children: <Widget>[
        Offstage(
          offstage: model.isShowSuspension != true,
          child: _buildSusWidget(susTag),
        ),
        Container(
          height: _itemHeight.toDouble(),
          child: ListTile(
            title: Text(model.name),
            leading: CircleAvatar(
              backgroundImage: NetworkImage(model.img),
            ),
            onTap: () {
              print("OnItemClick: ${model.id}");
              // Navigator.pop(context, model);
              setState(() {
                _currentCat = model;
                _cat_id = model.id;
              });
              _next();
            },
          ),
        )
      ],
    );
  }

  Widget pageDate() {
    return Container(
      padding: EdgeInsets.only(left: 46.0, right: 46.0),
      color: Colors.white,
      child: Column(
        children: <Widget>[
          SizedBox(
            height: ScreenUtil.getInstance().setWidth(100),
          ),
          Text(
            "宠物的生日",
            style: TextStyle(
              color: Color(0xFF647280),
              fontSize: 18.0,
            ),
          ),
          SizedBox(
            height: 30.0,
          ),
          GestureDetector(
            onTap: () {
              _showDatePicker();
            },
            child: Text(
              _dateTime == null
                  ? "请选择"
                  : _dateTime.year.toString() +
                      "年" +
                      _dateTime.month.toString() +
                      "月" +
                      _dateTime.day.toString() +
                      "日",
              style: TextStyle(
                color: Color(0xFF424D59),
                fontSize: 24.0,
              ),
            ),
          ),
          SizedBox(
            height: 25.0,
          ),
          Divider(
            height: 1.0,
            color: Color(0xFFDDDDDD),
          ),
          SizedBox(
            height: 25.0,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              _isDay ? _month() : _year(),
            ],
          ),
          SizedBox(
            height: 90.0,
          ),
          Text(
            "宠物的体重",
            style: TextStyle(
              fontSize: 18.0,
              color: Color(0xFF647280),
            ),
          ),
          SizedBox(
            height: 30.0,
          ),
          GestureDetector(
            child: Text(
              _weight == 0.0 ? "请选择" : _weight.toString() + "Kg",
              style: TextStyle(
                fontSize: 24.0,
                color: Color(0xFF424D59),
              ),
            ),
            onTap: () {
              showPickerNumber(context);
            },
          ),
          SizedBox(
            height: 15.0,
          ),
          Divider(
            height: 1.0,
            color: Color(0xFFDDDDDD),
          ),
          SizedBox(
            height: 25.0,
          ),
          Text(
            "布偶猫（标准）的正常体重范围是：",
            style: TextStyle(
              color: Color(0xFFB4BEC6),
              fontSize: 12.0,
            ),
          ),
          Text(
            "4.5kg ~ 9.0kg",
            style: TextStyle(
              color: Color(0xFFB4BEC6),
              fontSize: 12.0,
            ),
          ),
          Expanded(
            child: Container(),
          ),
          GestureDetector(
            onTap: () {
              ///进入主页面
              ///判断当前页是否完成
              if (complated3) {
                _next();
              }
            },
            child: ClipRRect(
              borderRadius: BorderRadius.circular(25.0),
              child: Container(
                alignment: Alignment.center,
                child: Text(
                  "下一步",
                  style: TextStyle(color: Color(0xFFFFFFFF), fontSize: 18.0),
                ),
                color: complated3 ? Color(0xFFFFCC33) : Color(0xFFFFE599),
                height: 50.0,
              ),
            ),
          ),
          SizedBox(
            height: 50.0,
          )
        ],
      ),
    );
  }

  _onSusTagChanged(String tag) {
    setState(() {
      _suspensionTag = tag;
    });
  }

  Widget _buildSusWidget(String susTag) {
    return Container(
      height: _suspensionHeight.toDouble(),
      padding: const EdgeInsets.only(left: 15.0),
      color: Color(0xfff3f4f5),
      alignment: Alignment.centerLeft,
      child: Text(
        '$susTag',
        softWrap: false,
        style: TextStyle(
          fontSize: 14.0,
          color: Color(0xff999999),
        ),
      ),
    );
  }

  Widget pageSex() {
    var bottomStyle = TextStyle(color: Color(0xFFB4BEC6), fontSize: 12.0);
    return Container(
      padding: EdgeInsets.only(left: 40.0, right: 40.0),
      color: Colors.white,
      child: Column(
        children: <Widget>[
          SizedBox(
            height: 50.0,
          ),
          Text(
            "宠物的性别",
            style: TextStyle(
              fontSize: 18.0,
              color: Color(0xFF647280),
            ),
          ),
          SizedBox(
            height: 30.0,
          ),
          GestureDetector(
            onTap: () {
              _showSexPicker();
            },
            child: Text(
              _sex,
              style: TextStyle(color: Color(0xFF424D59), fontSize: 24.0),
            ),
          ),
          SizedBox(
            height: 15.0,
          ),
          Divider(
            color: Color(0xFFDDDDDD),
            height: 1.0,
          ),
          SizedBox(
            height: 140.0,
          ),
          Text(
            "宠物的情史",
            style: TextStyle(
              fontSize: 18.0,
              color: Color(0xFF647280),
            ),
          ),
          SizedBox(
            height: 30.0,
          ),
          GestureDetector(
            onTap: () {
              _showHistoryPicker();
            },
            child: Text(
              _history,
              style: TextStyle(color: Color(0xFF424D59), fontSize: 24.0),
            ),
          ),
          SizedBox(
            height: 15.0,
          ),
          Divider(
            color: Color(0xFFDDDDDD),
            height: 1.0,
          ),
          SizedBox(
            height: 30.0,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              Text(
                "懵懂少年：0次",
                style: bottomStyle,
              ),
              Text(
                " 青涩初恋：1次",
                style: bottomStyle,
              )
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              Text(
                "久经情场：2 ~ 4次",
                style: bottomStyle,
              ),
              Text(
                "专业爸爸：5次以上",
                style: bottomStyle,
              ),
            ],
          ),
          Expanded(
            child: Container(),
          ),
          GestureDetector(
            onTap: () {
              ///提交数据
              _save();
            },
            child: ClipRRect(
              borderRadius: BorderRadius.circular(25.0),
              child: Container(
                alignment: Alignment.center,
                child: Text(
                  "保存",
                  style: TextStyle(color: Color(0xFFFFFFFF), fontSize: 18.0),
                ),
                color: complated4 ? Color(0xFFFFCC33) : Color(0xFFFFE599),
                height: 50.0,
              ),
            ),
          ),
          SizedBox(
            height: 50.0,
          )
        ],
      ),
    );
  }

  Widget _month() {
    return Row(
      children: <Widget>[
        Text(
          "今天",
          style: TextStyle(
            fontSize: 14.0,
            color: Color(0xFFB4BEC6),
          ),
        ),
        Text(
          _days.toString(),
          style: TextStyle(
            fontSize: 14.0,
            color: Color(0xFFFFCC33),
          ),
        ),
        Text(
          "月了",
          style: TextStyle(
            fontSize: 14.0,
            color: Color(0xFFB4BEC6),
          ),
        ),
      ],
    );
  }

  Widget _year() {
    return Row(
      children: <Widget>[
        Text(
          "今年",
          style: TextStyle(
            fontSize: 14.0,
            color: Color(0xFFB4BEC6),
          ),
        ),
        Text(
          _years.toString(),
          style: TextStyle(
            fontSize: 14.0,
            color: Color(0xFFFFCC33),
          ),
        ),
        Text(
          "岁了",
          style: TextStyle(
            fontSize: 14.0,
            color: Color(0xFFB4BEC6),
          ),
        ),
      ],
    );
  }

  void _next() {
    setState(() {
      _current++;
    });

    _pageController.jumpToPage(_current);
  }

  void _prev() {
    if (_current <= 0) {
      //回到上一级页面
      Navigator.of(context).pop();
    } else {
      //pageView回到上一级页面
      // _current--;
      setState(() {
        _current--;
      });
      _pageController.jumpToPage(_current);
    }
  }

  Future getImage() async {
    var image = await ImagePicker.pickImage(source: ImageSource.gallery);
    FileUtils.getInstance().uploadFile(image, (data) {
      Map<String, dynamic> dataMap = json.decode(data);
      if (dataMap["code"] == 200) {
        // _imgs.add(dataMap["data"]);
        setState(() {
          _image = dataMap["data"];
          complated1 = image != null && controller.text.length > 0;
        });
      }
      // print(data);
    });
  }

  void _handleList(List<PetCatInfo> list) {
    if (list == null || list.isEmpty) return;
    for (int i = 0, length = list.length; i < length; i++) {
      // String pinyin =
      //     PinyinHelper.convertToPinyinStringWithoutException(list[i].name);
      // String tag = pinyin.substring(0, 1).toUpperCase();
      // list[i].namePinyin = pinyin;
      // String pinyin = PinyinHelper.getPinyinE(list[i].name);
      // String tag = pinyin.substring(0, 1).toUpperCase();
      // list[i].en = pinyin;
      if (RegExp("[A-Z]").hasMatch(list[i].en)) {
        list[i].tagIndex = list[i].en;
      } else {
        list[i].tagIndex = "#";
      }
    }
    //根据A-Z排序
    SuspensionUtil.sortListBySuspensionTag(_catList);
  }

  /// Display number picker
  showPickerNumber(BuildContext context) {
    Picker(
        adapter: NumberPickerAdapter(data: [
          NumberPickerColumn(
            begin: 0,
            end: 20,
          ),
          NumberPickerColumn(
            begin: 1,
            end: 9,
          ),
        ]),
        delimiter: [
          PickerDelimiter(
              child: Container(
            width: 30.0,
            alignment: Alignment.center,
            child: Icon(Icons.more_vert),
          ))
        ],
        hideHeader: true,
        title: Text("选择体重"),
        onConfirm: (Picker picker, List value) {
          var wieght = value[0] + (value[1] + 1) / 10;
          setState(() {
            _weight = wieght;
            complated3 = _weight != 0.0;
            weight = (_weight * 1000) ~/ 1;
          });
        }).showDialog(context);
  }

  /// Display date picker.
  void _showDatePicker() {
    DatePicker.showDatePicker(
      context,
      pickerTheme: DateTimePickerTheme(
        showTitle: _showTitle,
        confirm: Text(
          '确认',
          style: TextStyle(color: Colors.cyan),
        ),
        cancel: Text(
          '取消',
          style: TextStyle(color: Colors.red),
        ),
      ),
      minDateTime: DateTime.parse(MIN_DATETIME),
      maxDateTime: DateTime.parse(MAX_DATETIME),
      initialDateTime: _dateTime,
      dateFormat: _format,
      locale: _locale,
      onConfirm: (dateTime, List<int> index) {
        setState(() {
          _dateTime = dateTime;
          // int.
          birthday = dateTime.millisecondsSinceEpoch ~/ 1000;
        });
        var tmp = dateTime;

        ///判断小狗的年龄
        if (_nowTime.difference(_dateTime).inDays > 365) {
          var yearD = Duration(days: 365);
          _isDay = false;

          ///相差天数大于365天
          var years = 1;
          while (!_nowTime.isBefore(tmp.add(yearD))) {
            tmp = tmp.add(yearD);
            years = years + 1;
            // print(years);
          }

          setState(() {
            _years = years;
          });
        } else {
          ///相差天数小于365填
          var yearD = Duration(days: 30);
          _isDay = true;
          var days = 1;
          while (!_nowTime.isBefore(tmp.add(yearD))) {
            tmp = tmp.add(yearD);
            days++;
          }
          setState(() {
            _days = days;
          });
        }
        //print();
      },
    );
  }

  ///显示性别
  _showSexPicker() {
    Picker(
        confirmText: "确认",
        cancelText: "取消",
        adapter: PickerDataAdapter<String>(pickerdata: SEXS),
        changeToFirst: true,
        hideHeader: false,
        onConfirm: (Picker picker, List value) {
          // print(value.toString());
          print(picker.adapter.text);
          setState(() {
            sex = (value[0] + 1).toString();
            _sex = SEXS[value[0]];
            //  complated4 = sex!="" &&
          });
        }).show(_scaffoldKey.currentState);
  }

  ///显示婚恋史
  _showHistoryPicker() {
    Picker(
      confirmText: "确认",
      cancelText: "取消",
      adapter: PickerDataAdapter<String>(pickerdata: HISTORY),
      changeToFirst: true,
      hideHeader: false,
      onConfirm: (Picker picker, List value) {
        // print(value.toString());
        // print(picker.adapter.text);
        setState(() {
          history = (value[0] + 1).toString();
          _history = HISTORY[value[0]];
          //  complated4 = sex!="" &&
        });
      },
    ).show(_scaffoldKey.currentState);
  }

  _getCat(int parent) {
    setState(() {
      finished = false;
    });
    getCats(parent.toString()).listen((CatsEntity data) {
      // print(data);
      _cat_data = data.data;

      ///清除所有列表
      _catList.clear();
      List<PetCatInfo> tmp = List();
      for (CatsData item in data.data) {
        // _catList.add(PetCatInfo(item., img, name, en));
        for (CatsDataData it in item.data) {
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
          tmp.add(PetCatInfo(it.id.toString(), it.imgs, it.name, item.letter));
        }
      }
      // print("或渠道数据");
      // print(_catList);
      // _handleList(list)
      _catList = tmp;
      _handleList(_catList);
      setState(() {
        finished = true;
      });
      // setState(() {
      //   _catList = tmp;
      //   print(_catList.length);
      // });
    });
  }

  _getGroup() {
    getCatGroup().listen((CatGroupEntity data) {
      // print(data);
      if (data.code == 200) {
        setState(() {
          _main_cat = data.data;
          _current_main_cat = data.data[0].id;
          finished = true;
        });
        _getCat(_current_main_cat);
      }
    });
  }

  _save() {
    setState(() {
      finished = false;
    });
    animal(_image, controller.text, birthday, weight, _cat_id, "",
            _current_main_cat.toString(), sex, history)
        .listen((SuccessEntity data) {
      setState(() {
        finished = true;
      });
      if (data.code == 200) {
        alert("添加成功");

        ///向主页面发送事件更新主页面数据
         Navigator.of(context).pushNamed(HomePath);
      }
    }).onError((e) {
      setState(() {
        finished = true;
      });
      alert("添加失败,请重试~");
    });
  }
}

///宠物分类的模型类
class PetCatInfo extends ISuspensionBean {
  String tagIndex;
  String id;
  String img;
  String name;
  String en;
  PetCatInfo(this.id, this.img, this.name, this.en);

  @override
  String getSuspensionTag() => tagIndex;
}
